<template>
    <Crud :table="table" :columns="columns" v-model:saveFormData="saveFormData" v-model:searchObj="searchObj"
          :showAdd="false" :showDelete="()=>false">
        <template #save>
            <a-form
                ref="save_form"
                :model="saveFormData"
                :label-col="{ span: 6 }"
                :wrapper-col="{ span: 18 }"
            >
              <a-form-item label="昵称" name="nickname" :rules="[{ required: true, message: '' }]">
                <a-input v-model:value="saveFormData.nickname"/>
              </a-form-item>
              <a-form-item label="用户名" name="username" :rules="[{ required: true, message: '' }]">
                  <a-input v-model:value="saveFormData.username"/>
              </a-form-item>
              <a-form-item label="手机号" name="tel" :rules="[{ required: true, message: '' }]">
                  <a-input v-model:value="saveFormData.tel"/>
              </a-form-item>
              <a-form-item label="余额" name="money">
                  <a-input v-model:value="saveFormData.money"/>
              </a-form-item>
              <a-form-item label="虚拟币" name="v_money">
                <a-input v-model:value="saveFormData.v_money"/>
              </a-form-item>
              <a-form-item label="是否团长" name="is_leader">
                <a-select
                    v-model:value="saveFormData.is_leader"
                    placeholder="是否团长"
                    :options="[{label:'是',value:1},{label:'否',value:0}]"
                >
                </a-select>
              </a-form-item>
              <a-form-item label="是否代理" name="is_agent">
                <a-select
                    v-model:value="saveFormData.is_agent"
                    placeholder="是否代理"
                    :options="[{label:'是',value:1},{label:'否',value:0}]"
                >
                </a-select>
              </a-form-item>
              <a-form-item label="上级" name="share_id">
                <RemoteSelect placeholder="用户" table="user" name_key="nickname" v-model:value="saveFormData.share_id"/>
              </a-form-item>
              <a-form-item label="头像" name="avatar_img">
                  <Upload :maxCount="1" v-model:value="saveFormData.avatar_img"/>
              </a-form-item>
              <a-form-item label="角色" name="role_id">
                <RemoteSelect table="role" name_key="role_name" v-model:value="saveFormData.role_id"/>
              </a-form-item>


            </a-form>
        </template>
        <template #search>
            <a-form
                layout="inline"
            >
              <a-form-item>
                  <a-input placeholder="用户ID" v-model:value="searchObj.user_id"/>
              </a-form-item>
              <a-form-item>
                  <a-input placeholder="手机号" v-model:value="searchObj.tel"/>
              </a-form-item>
              <a-form-item>
                  <a-input placeholder="用户名" v-model:value="searchObj.username"/>
              </a-form-item>
              <a-form-item>
                <a-input placeholder="昵称" v-model:value="searchObj.nickname"/>
              </a-form-item>
              <a-form-item>
                <a-select
                    v-model:value="searchObj.is_leader"
                    placeholder="是否团长"
                    :options="[{label:'是',value:1},{label:'否',value:0}]"
                >
                </a-select>
              </a-form-item>
              <a-form-item>
                <a-select
                    v-model:value="searchObj.is_agent"
                    placeholder="是否代理"
                    :options="[{label:'是',value:1},{label:'否',value:0}]"
                >
                </a-select>
              </a-form-item>
              <a-form-item>
                <RemoteSelect placeholder="上级" table="user" name_key="nickname" v-model:value="searchObj.share_id"/>
              </a-form-item>
              <a-form-item >
                <RemoteSelect placeholder="角色" table="role" name_key="role_name" v-model:value="searchObj.role_id"/>
              </a-form-item>
            </a-form>
        </template>
    </Crud>
</template>

<script>

export default {
    name: "list",
    data: function () {
        return {
            table: 'user',
            saveFormData: {},
            searchObj: {},
            columns: [
                {
                    title: '昵称',
                    key: 'nickname',
                },{
                    title: '用户名',
                    key: 'username',
                }, {
                    title: '手机号',
                    key: 'tel',
                }, {
                    title: '余额',
                    key: 'money',
                }, {
                    title: '虚拟币',
                    key: 'v_money',
                }, {
                    title: '头像',
                    key: 'avatar_img',
                }, {
                    title: '是否团长',
                    key: 'is_leader',
                },{
                    title: '是否代理',
                    key: 'is_agent',
                },{
                    title: '团长比例',
                    key: 'leader_rate',
                },{
                    title: '代理比例',
                    key: 'agent_rate',
                },{
                    title: '注册时间',
                    key: 'add_time',
                },
            ],
        };
    },
    computed: {
        table_key() {
            return `${this.table}_id`
        },
    },
    components: {},
    created() {
    },
    methods: {}
}
</script>

<style scoped lang="less">
</style>